package com.iss.demo.dao;

import com.iss.demo.entity.Book;
import com.iss.demo.entity.Order;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;


import java.util.List;

@Mapper
@Repository
public interface BookDao {
    @Select("select * from book")
    public List<Book> selectAll();

    @Insert("insert into book (b_id,b_carbrand,b_carname,b_call,b_username,b_phone,b_time,u_id,u_dealer,u_status) value(null,#{b_carbrand},#{b_carname}," +
            "#{b_call},#{b_username},#{b_phone},CURRENT_TIMESTAMP,#{u_id},#{u_dealer},'等待确认')")
    public Integer insertBook(Book book);

    @Delete("delete from book where b_id=#{b_id}")
    public Integer deleteOne(Integer b_id);

    @Update("UPDATE book set u_status = '已确认' where b_id = #{b_id} ")
    public Integer updateBook(Integer b_id);

    @Select("SELECT * from book where u_id=#{u_id}")
    public List<Book> selectAllById(Integer u_id);

}
